<template>
	<view class="scenic-container mainpadding mainbgc" v-show="show">
		<view class="search">
			<u-search borderColor="#00D2E1" bgColor="transparent" placeholder="地名/民宿/关键词" :showAction="false"
				v-model="keyword" @search="init()"></u-search>
		</view>
		<view class="flexcenter1" v-if="!list.data.length">
			<view class="placeholderimg" style="margin-top: 300rpx;">
				<image src="../../static/images/bg-icons/placeholderimg.png" mode=""></image>
			</view>
			<view class="zanwushuju">暂无数据~</view>
		</view>
		<view class="scenic-list">
			<view class="scenic-item mainpadding ffffff" v-for="(item,index ) in list.data" :key="item.id" @click="toDetaiL(item.id)">
				<view class="img">
					<image :src="item.image_text" mode=""></image>
				</view>
				<view class="scenic-detail">
					<view class="title lhxiankuan" style="font-size: 30rpx;">{{item.name}}</view>
					<view class="bottom">
						<view class="price"  style="font-size: 36rpx;">￥{{item.goodsprice.price}}起</view>
						<view class="count"  style="font-size: 30rpx;">已售{{item.sales_num}}</view>
					</view>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				keyword: '',
				page: 1,
				limit: 12,
				list: {
					data: []
				},
				show:false,
			}
		},
		onLoad() {
			this.init()
		},
		
		methods: {
			onShareAppMessage(res) {
				let path='/pages/hotel/jiudian';
				if(uni.getStorageSync('user_id')){
					path='/pages/hotel/jiudian?referee_id='+uni.getStorageSync('user_id');
				}
				return {
					title: '季忆水雲乡',
					path:path,
					// imageUrl:'../../static/person_img.png'
					
				}
			},
			onShareTimeline(res) {
				let path='/pages/hotel/jiudian';
				if(uni.getStorageSync('user_id')){
					path='/pages/hotel/jiudian?referee_id='+uni.getStorageSync('user_id');
				}
				return {
					title: '季忆水雲乡',
					path:path,
					// imageUrl:'../../static/person_img.png'
					
				}
			},
			init(isPage, page) {
				let _this = this;
				httpRequest.request('api/tour/tourList', 'GET', {
					page: page || 1,
					limit: _this.limit,
					keywords: this.keyword,
				}, false, false, false).then(res => {
					this.show=true
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage === true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					this.show=true
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			toDetaiL(id) {
				uni.navigateTo({
					url: '/pages/scenic/scenic-detail?id='+id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.scenic-list {
		margin-top: 30rpx;
	}

	.scenic-item {
		display: flex;
		border-radius: 14rpx;
		box-sizing: border-box;
		margin-bottom: 30rpx;
	}

	.img {
		width: 199rpx;
		height: 209rpx;
		margin-right: 22rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.title {
		height: 75rpx;
		font-size: 28rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #000000;
	}

	.scenic-detail {
		flex: 1;
	}

	.bottom {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-top: 83rpx;
	}

	.price {
		font-size: 29rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #FF5C00;
	}

	.count {
		font-size: 24rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #666666;
	}
</style>
